/*
 * @Descripttion:调用后端订单接口的函数
 */

import axios from 'axios'

// 创建订单
const makeOrder = order =>
	axios.post('/api/test/user/makeOrder', {
		userId: order.userId,
		commodityId: order.commodityId,
		number: order.number,
		channel: order.channel,
		time: order.time,
	}).then(res => res.data)

// 读取订单
const listOrders = (user_id) =>
	axios.get('/api/test/shop/user/order', {
		params: {
			accountId: user_id,
		}
	})
	.then(res => res.data)

// 读取订单详情
const showOrder = order_id =>
	axios.get(`/api/test/shop/order`, {
		params: {
			orderId: order_id,
		}
	}).then(res => res.data)

//获取订单计数
const getCount = user_id => axios.get('/api/test/orderCount', {
	params:{
		userId: user_id,
	}
}).then(res => res.data)

export {
	makeOrder,
	listOrders,
	showOrder,
	getCount,
}
